<template>
  <div>
    <div class="component-mainHeader">
      <div class="top">
        <div class="topleft">
          <p>
            <span class="iconfont" style="color:#1abc9a;margin-right:3px;">&#xe607;</span>待处理材料
          </p>
        </div>
        <div class="topright">
         <!-- <el-button type="info" @click="$router.go(-1)">
            <span style="font-weight:700;margin-right:5px;" class="iconfont">&#xe606;</span>返回
          </el-button>-->
          <el-button type="info" @click="$router.go(0)">
            <span style="font-weight:700;margin-right:5px;" class="iconfont">&#xe662;</span>刷新
          </el-button>
        </div>
      </div>
    </div>
    <div class="component-listHeader">
      <div class="search-header">
        <div class="left-title">
          <p class="left-text">
            <span class="iconfont">&#xe61e;</span>
            待处理材料
          </p>
          <div class="right">
            <!-- <button  @click="add">添加</button> -->
          </div>
        </div>
      </div>
    </div>

    <div class="table">
      <el-table
        ref="multipleTable"
        :data="info"
        tooltip-effect="dark"
        style="width:100%"
        border
      >
        <el-table-column label="时间" align="center">
          <template slot-scope="scope">
            {{scope.row.createDate | dateFilter}}
          </template>
        </el-table-column>
        <el-table-column label="采购单号" align="center" prop="buyNo"></el-table-column>
        <el-table-column label="申请总价" align="center" prop="buyMoney"></el-table-column>
        <el-table-column label="审核状态" align="center">
          <template slot-scope="scope">
            <div>
              <span v-if="scope.row.flowStatus == '00'">未提交审核</span>
              <span v-if="scope.row.flowStatus == '10'">待项目部文员审核</span>
              <span v-if="scope.row.flowStatus == '11'">项目部文员审核通过</span>
              <span v-if="scope.row.flowStatus == '19'">项目部文员驳回</span>
              <span v-if="scope.row.flowStatus == '20'">待项目经理审核</span>
              <span v-if="scope.row.flowStatus == '21'">项目经理通过</span>
              <span v-if="scope.row.flowStatus == '29'">项目经理驳回</span>
            </div>
            <div><a class="options" @click.prevent="opinion(scope.row)">审核意见</a></div>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <!--未审核的才有审核意见-->
            <a class="options" @click.prevent="$router.push({name:'seDetail',params:{flag:1,id:scope.row.buyId}})">查看详情</a>
            <a v-if="scope.row.flowStatus == 11 || scope.row.flowStatus == 21" class="options" @click.prevent="purchase(scope.row.buyId,scope.row.buyNo)">采购入库</a>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 分页 -->
    <div class="component-paging" v-if="info.length > 1">
      <div class="table-bottom">
        <div class="bottom-left"></div>
        <div class="paging">
          <div class="paging-left">
            <p>
              共
              <span>{{Math.ceil(total/pageSize)}}</span> 页/
              <span>{{total}}</span> 条数据
            </p>
          </div>
          <el-pagination
            background
            @size-change="SizeChange($event,dataInit,currentPage,pageSize)"
            @current-change="CurrentChange($event,dataInit,currentPage,pageSize)"
            :current-page="currentPage"
            :page-sizes="[10, 20, 30]"
            :page-size="pageSize"
            layout="sizes, prev, pager, next, jumper"
            :total="total"
          ></el-pagination>
        </div>
      </div>
    </div>

    <!--审核意见弹框-->
    <div class="component-model">
      <el-dialog title="审核记录" :visible.sync="dialogAdd" width="800px" class="component-modelMater">
        <el-table
          ref="multipleTable"
          :data="infoOptions"
          tooltip-effect="dark"
          style="width:100%"
          border
        >
          <el-table-column label="审核时间" align="center">
            <template slot-scope="scope">
              {{scope.row.updateDate | dateFilter}}
            </template>
          </el-table-column>
          <el-table-column label="审核人员" align="center" prop="checkUser"></el-table-column>
          <el-table-column label="审核结果" align="center" prop="buyMoney">
            <template slot-scope="scope">
              <span v-if="scope.row.flowStatus == '00'">未提交审核</span>
              <span v-if="scope.row.flowStatus == '10'">待项目部文员审核</span>
              <span v-if="scope.row.flowStatus == '11'">项目部文员审核通过</span>
              <span v-if="scope.row.flowStatus == '19'">项目部文员驳回</span>
              <span v-if="scope.row.flowStatus == '20'">待项目经理审核</span>
              <span v-if="scope.row.flowStatus == '21'">项目经理通过</span>
              <span v-if="scope.row.flowStatus == '29'">项目经理驳回</span>
            </template>
          </el-table-column>
          <el-table-column label="反馈详情" align="center" prop="checkOpinion"></el-table-column>
        </el-table>
      </el-dialog>
    </div>

  </div>
</template>

<script>
  import crypto from 'crypto';
  export default {
    data() {
      return {
        info: [],
        dialogAdd:false,
        infoOptions:[],
        inId:'',
        // 数据总条数
        total: 1,
        // 每页显示数据的条数
        pageSize: 10,
        // 当前显示的页面页码
        currentPage: 1
      };
    },
    created(){

    },
    mounted(){
      this.dataInit();
    },
    methods: {
      dataInit(){
        let that = this;
        let suCb = function(res){
          that.info = res.data.data.list;
          that.total = res.data.data.rowCount;
          console.log(res.data)
        }
        let erCb = function(res){
          console.log(res)
        }
        let postData = {
          buySource:'1',
          pageCurrent:that.currentPage,
          pageSize:that.pageSize
        }
        let palyParam = {
          url: "/api/web/proBuyApply/getCheckList",
          methods:'post',
          data: postData,
          success: suCb,
          error: erCb,
        }
        that.$https(palyParam)
      },
      //审核意见
      opinion(row){
        this.dialogAdd = true;
        let arr = [];
        arr.push(row);
        this.infoOptions = arr;
//        console.log(this.infoOptions)
      },
      //点击入库
      purchase(val,val1){
        let str = new Date().getTime().toString();
        this.getmd5(str,val,val1);
      },
      //md5加密
      getmd5(n,val,val1){
        let md5 = crypto.createHash("md5");
        md5.update(n);
        let num = md5.digest('hex');
        this.inId = num;
        this.$router.push({name:'procurementList',params:{flag:0,inId:this.inId,buyId:val,undo:1,buyNo:val1}});
//        console.log(this.inId);
      },
    },
    watch: {}

  };
</script>
<style scoped>
  .component-listHeader .search-header {
    width: 1100px;
    box-sizing: border-box;
    border: 1px solid rgba(228, 228, 228, 1);
    background-color: rgba(255, 255, 255, 1);
    margin: 20px auto 0;
    border-bottom: 0;
  }

  .component-listHeader .search-header .left-title {
    display: flex;
    justify-content: space-between;
    width: 100%;
    background-color: rgba(243, 243, 243, 1);
    height: 45px;
    box-sizing: border-box;
  }

  .component-listHeader .search-header .left-title .left-text {
    width: 20%;
    color: #666;
    font-family: "微软雅黑";
    font-weight: 400;
    font-size: 12px;
    line-height: 45px;
    text-align: left;
    margin: 0 0 0 30px;
  }

  .component-listHeader .search-header .right {
    width: 70%;
    display: flex;
    justify-content: flex-end;
    margin-right: 10px;
  }

  .component-listHeader .search-header .right button {
    padding: 0 15px;
    height: 30px;
    width: 80px;
    margin: 6px 5px;
    line-height: 30px;
    font-size: 14px;
    color: #666;
    background-color: #fff;
    border: 1px solid #ccc;
  }

  .component-listHeader .search-header .right button:hover {
    background-color: #f3f3f3;
  }

  .component-listHeader .search-header .right .right-select-margin {
    margin-top: 6px;
    margin-right: 8px;
  }
  .table{
    width: 1100px;
    margin: 0 auto;
  }
  a{
    cursor: pointer;
    color: #1ABC9C;
  }
</style>
